/*
 * Copyright 2007 Peter Zelenay.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *     
 */
package net.zelenay.jcrviewer;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;

import javax.swing.JComponent;
import javax.swing.JFrame;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * .
 * 
 * @author Peter Zelenay
 * 
 */
public class MainFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static final Log LOG = LogFactory.getLog(MainFrame.class);

	private JComponent tree;
	
	private JComponent table;

	public MainFrame() throws HeadlessException {
		super("JCR Viewer");
		setLayout(new GridBagLayout());
	}

	/**
	 * @return the tree
	 */
	public JComponent getTree() {
		return tree;
	}

	/**
	 * @param aTree
	 *            the tree to set
	 */
	public void setTree(JComponent aTree) {
		if (tree != null) {
			remove(tree);
		}
		this.tree = aTree;
		GridBagConstraints cs = new GridBagConstraints();
		cs.anchor = GridBagConstraints.FIRST_LINE_START;
		cs.fill = GridBagConstraints.BOTH;
		cs.weightx = 0.3d;
		cs.weighty = 0.3d;
		add(tree,cs);
	}

	public JComponent getTable() {
		return table;
	}

	public void setTable(JComponent aTable) {
		if (table != null) {
			remove(table);
		}
		table = aTable;
		GridBagConstraints cs = new GridBagConstraints();
		cs.anchor = GridBagConstraints.FIRST_LINE_START;
		cs.fill = GridBagConstraints.BOTH;
		cs.gridx = 1;
		cs.weightx = 0.7d;
		cs.weighty = 0.7d;
		add(table,cs);
	}
	
	

}
